package edu.chl.da.ejb.core;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * This class is the primary key for a hotel reservation.
 * @author Jakob
 */
@Embeddable
public class HotelreservationPK implements Serializable {
    @Basic(optional = false)
    @Column(name = "BOOKINGNUMBER")
    private int bookingnumber;
    @Basic(optional = false)
    @Column(name = "FROMAIRPORT")
    private String fromairport;
    @Basic(optional = false)
    @Column(name = "FROMDESTINATION")
    private String fromdestination;
    @Basic(optional = false)
    @Column(name = "AIRPLANE")
    private int airplane;
    @Basic(optional = false)
    @Column(name = "SEATNO")
    private int seatno;
    @Basic(optional = false)
    @Column(name = "SEATROW")
    private int seatrow;
    @Basic(optional = false)
    @Column(name = "CUSTOMER")
    private String customer;

    public HotelreservationPK() {
    }

    public HotelreservationPK(int bookingnumber, String fromairport, String fromdestination, int airplane, int seatno, int seatrow, String customer) {
        this.bookingnumber = bookingnumber;
        this.fromairport = fromairport;
        this.fromdestination = fromdestination;
        this.airplane = airplane;
        this.seatno = seatno;
        this.seatrow = seatrow;
        this.customer = customer;
    }

    public int getBookingnumber() {
        return bookingnumber;
    }

    public void setBookingnumber(int bookingnumber) {
        this.bookingnumber = bookingnumber;
    }

    public String getFromairport() {
        return fromairport;
    }

    public void setFromairport(String fromairport) {
        this.fromairport = fromairport;
    }

    public String getFromdestination() {
        return fromdestination;
    }

    public void setFromdestination(String fromdestination) {
        this.fromdestination = fromdestination;
    }

    public int getAirplane() {
        return airplane;
    }

    public void setAirplane(int airplane) {
        this.airplane = airplane;
    }

    public int getSeatno() {
        return seatno;
    }

    public void setSeatno(int seatno) {
        this.seatno = seatno;
    }

    public int getSeatrow() {
        return seatrow;
    }

    public void setSeatrow(int seatrow) {
        this.seatrow = seatrow;
    }

    public String getCustomer() {
        return customer;
    }

    public void setCustomer(String customer) {
        this.customer = customer;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) bookingnumber;
        hash += (fromairport != null ? fromairport.hashCode() : 0);
        hash += (fromdestination != null ? fromdestination.hashCode() : 0);
        hash += (int) airplane;
        hash += (int) seatno;
        hash += (int) seatrow;
        hash += (customer != null ? customer.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HotelreservationPK)) {
            return false;
        }
        HotelreservationPK other = (HotelreservationPK) object;
        if (this.bookingnumber != other.bookingnumber) {
            return false;
        }
        if ((this.fromairport == null && other.fromairport != null) || (this.fromairport != null && !this.fromairport.equals(other.fromairport))) {
            return false;
        }
        if ((this.fromdestination == null && other.fromdestination != null) || (this.fromdestination != null && !this.fromdestination.equals(other.fromdestination))) {
            return false;
        }
        if (this.airplane != other.airplane) {
            return false;
        }
        if (this.seatno != other.seatno) {
            return false;
        }
        if (this.seatrow != other.seatrow) {
            return false;
        }
        if ((this.customer == null && other.customer != null) || (this.customer != null && !this.customer.equals(other.customer))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.chl.da.ejb.core.HotelreservationPK[bookingnumber=" + bookingnumber + ", fromairport=" + fromairport + ", fromdestination=" + fromdestination + ", airplane=" + airplane + ", seatno=" + seatno + ", seatrow=" + seatrow + ", customer=" + customer + "]";
    }

}
